﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using WorkStation.Frameworks.EasyBus;
using WorkStation.Frameworks.EasyBus.Serializable;
using WorkStation.Frameworks.EasyBus.MessageQueue;
using WorkStation.Frameworks.EasyBus.MessageQueue.RabbitMq;
using WorkStation.Frameworks.EasyBus.Attributes;
using WorkStation.Frameworks.EasyBus.Extensions;
using WorkStation.Frameworks.EasyBus.Repositories.Mongo;
using WorkStation.Frameworks.EasyBus.Repositories.ZooKeeper;

namespace WorkStation.Frameworks.EasyBus.Test.Publish
{
    class Program
    {
        static void Main(string[] args)
        {
            ServiceContainer.Current.UseServiceLocator(new RabbitMqAddressTranslator());

            IBus bus = EasyBus.GetInstance("EasyTest.Publish", "ServerA").SetAttributeConfigProvider("WorkStation.Frameworks.EasyBus.Test.Publish")
                                                                         .UserZooKeeper("10.32.33.140:2181", new TimeSpan(0, 0, 0, 20, 0))
                                                                         .UserMongodb("mongodb://10.32.11.131")
                                                                         .Start();

            while (true) 
            {
                Console.WriteLine("Input command:");
                string command = Console.ReadLine();

                if (command.Equals("send"))
                {
                    bus.Publish(new Message(new PublishMessage() { Name = "AKB48" }, "EasyBus.PublishMessage"));
                }
                else
                {
                    return;
                }
            }
        }
    }

    [Publish(RouteKey = "EasyBus.PublishMessage", Description = "测试订单消息")]
    public class PublishMessage 
    {
        public string Name { get; set; }
    }
}
